package com.example.controller;

import com.example.pojo.Stock;
import com.example.service.StockFreezeTccService;
import com.example.service.StockService;
import com.example.service.StockTccService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("stock")
public class StockController 
{
	@Autowired
	StockService stockService;

//	@GetMapping("getPrice")
//	public Integer getPrice(@RequestParam("id") Integer id)
//	{
//		return stockService.getById(id).getPrice();
//	}
	
//	@Autowired
//	StockTccService stockTccService;

	@GetMapping("reduce")
	public void reduce(@RequestParam("id") Integer id)
	{
		stockService.reduce(id,1);
//		stockTccService.reduce(id,1);
//		stockService.reduce(id,1);
//		Stock stock = stockService.getById(id);
//		Integer amount = stock.getAmount();
//		if(amount==0) 
//			throw new RuntimeException("库存不足");
//		amount-=1;
//		stock.setAmount(amount);
//		stockService.updateById(stock);
	}
}
